﻿@model MatchEventSummaryViewModel

@{ ViewBag.Title = "Starters"; }

<div class="grid_2">
    @Html.LabelFor(m => m.MatchSummaryViewModel.MatchDate)
</div>
<div class="grid_10 clearfix">    
    @Html.Label(Model.MatchSummaryViewModel.MatchDate)
</div>

<div class="grid_2">
    @Html.LabelFor(m => m.MatchSummaryViewModel.CompetitionName)
</div>
<div class="grid_10 clearfix">    
    @Html.Label(Model.MatchSummaryViewModel.CompetitionName)
</div>

<div class="grid_2">
    @Html.LabelFor(m => m.MatchSummaryViewModel.VenueName)
</div>
<div class="grid_10 clearfix">    
    @Html.Label(Model.MatchSummaryViewModel.VenueName)
</div>

<div class="grid_5" style="text-align:right">    
    @Html.Label(Model.MatchSummaryViewModel.Team1Name)
</div>

<div class="grid_2" style="text-align:center">    
    @Html.Label(Model.MatchSummaryViewModel.FullTimeScore)
</div>

<div class="grid_5 clearfix">    
    @Html.Label(Model.MatchSummaryViewModel.Team2Name)
</div>

<div class="grid_12 clearfix" style="text-align:center">
    <h3>Select players who started the match.</h3>
</div>

@using (Html.BeginForm(FormMethod.Post)) 
{
    @Html.AntiForgeryToken()
    @Html.HiddenFor(m => m.MatchGuid)


    <div class="grid_5" style="text-align:right">
        @for (int i = 0; i < Model.MatchEvent1DataModels.ToArray().Count(); i++)
        {
            <div>
                @Html.HiddenFor(m => m.MatchEvent1DataModels[i].MatchEventGuid)
                @Html.HiddenFor(m => m.MatchEvent1DataModels[i].ApprovalGuid)
                @Html.HiddenFor(m => m.MatchEvent1DataModels[i].MatchGuid)
                @Html.HiddenFor(m => m.MatchEvent1DataModels[i].TeamGuid)

                @(Html.Kendo().ComboBoxFor(m => m.MatchEvent1DataModels[i].PersonGuid)
                    .DataValueField("Code")
                    .DataTextField("Description") 
                    .MinLength(2)
                    .Filter(FilterType.Contains)
                    .Delay(150)
                    .Placeholder("[Select player]")
                    .HighlightFirst(true)
                    .IgnoreCase(true)
                    .Suggest(true)
                    .HtmlAttributes(new { style = "width: 300px" })
                    .DataSource(source => { source.Read(read => { read.Action("GetPeopleJSON", "Edit"); }).ServerFiltering(true); })
                )
            </div>
        } 

        <div>Select new starter</div>

        <div>
            @Html.HiddenFor(m => m.NewTeam1MatchEvent.MatchGuid)
            @Html.HiddenFor(m => m.NewTeam1MatchEvent.TeamGuid)
            @Html.HiddenFor(m => m.NewTeam1MatchEvent.MatchEventType)

            @(Html.Kendo().ComboBoxFor(m => m.NewTeam1MatchEvent.PersonGuid)
                .DataValueField("Code")
                .DataTextField("Description") 
                .MinLength(2)
                .Filter(FilterType.Contains)
                .Delay(150)
                .Placeholder("[Select player]")
                .HighlightFirst(true)
                .IgnoreCase(true)
                .Suggest(true)
                .Value(string.Empty)
                .HtmlAttributes(new { style = "width: 300px" })
                .DataSource(source => { source.Read(read => { read.Action("GetPeopleJSON", "Edit"); }).ServerFiltering(true); })
            )
        </div>
    </div>

    <div class="grid_2">&nbsp;</div>
    
    <div class="grid_5 clearfix">
        @for (int i = 0; i < Model.MatchEvent2DataModels.ToArray().Count(); i++)
        {
            <div>
                @Html.HiddenFor(m => m.MatchEvent2DataModels[i].MatchEventGuid)
                @Html.HiddenFor(m => m.MatchEvent2DataModels[i].ApprovalGuid)
                @Html.HiddenFor(m => m.MatchEvent2DataModels[i].MatchGuid)
                @Html.HiddenFor(m => m.MatchEvent2DataModels[i].TeamGuid)

                @(Html.Kendo().ComboBoxFor(m => m.MatchEvent2DataModels[i].PersonGuid)
                    .DataValueField("Code")
                    .DataTextField("Description") 
                    .MinLength(2)
                    .Filter(FilterType.Contains)
                    .Delay(150)
                    .Placeholder("[Select player]")
                    .HighlightFirst(true)
                    .IgnoreCase(true)
                    .Suggest(true)
                    .HtmlAttributes(new { style = "width: 300px" })
                    .DataSource(source => { source.Read(read => { read.Action("GetPeopleJSON", "Edit"); }).ServerFiltering(true); })
                )
            </div>
        } 

        <div>Select new starter</div>

        <div>
            @Html.HiddenFor(m => m.NewTeam2MatchEvent.MatchGuid)
            @Html.HiddenFor(m => m.NewTeam2MatchEvent.TeamGuid)
            @Html.HiddenFor(m => m.NewTeam2MatchEvent.MatchEventType)

            @(Html.Kendo().ComboBoxFor(m => m.NewTeam2MatchEvent.PersonGuid)
                .DataValueField("Code")
                .DataTextField("Description") 
                .MinLength(2)
                .Filter(FilterType.Contains)
                .Delay(150)
                .Placeholder("[Select player]")
                .HighlightFirst(true)
                .IgnoreCase(true)
                .Suggest(true)
                .Value(string.Empty)
                .HtmlAttributes(new { style = "width: 300px" })
                .DataSource(source => { source.Read(read => { read.Action("GetPeopleJSON", "Edit"); }).ServerFiltering(true); })
            )
        </div>
    </div>
    
    <div class="grid_12 clearfix" style="text-align:center">
        <br />
        <button class="k-button" type="submit" id="submitButton">
            <span class="k-icon k-i-tick"></span>
            <span>Save</span>
        </button>
    </div>
    
    <div class="grid_12 clearfix" style="text-align:right;">
        @Html.ActionLink("Continue to match events", "Events", "Edit", new { id = Model.MatchGuid }, null)
    </div>
}